Most video coding applications constrain the encoder to compress the input video at a given target bit rate. In order to achieve this, the encoder uses a rate control system. A rate control system allocates a number of bits to each picture in the input video source and adjusts encoding parameters to match the allocated number of bits. The performance of a rate control system is measured by the accuracy in meeting the target bit rate and the visual quality of the compressed video. In video coding standards such as the International Organization for Standardization/International Electrotechnical Commission (ISO/IEC) Moving Picture Experts Group-2 Standard (hereinafter the “MPEG-2 Standard”), the ISO/IEC Moving Picture Experts Group-4 (MPEG-4) Part 10 Advanced Video Coding (AVC) Standard/International Telecommunication Union, Telecommunication Sector (ITU-T) H.264 Recommendation (hereinafter the “MPEG-4 AVC Standard”), and the Society of Motion Picture and Television Engineers (SMPTE) Video Codec-1 Standard (hereinafter the “VC-1 Standard”), there are several quantization parameters that influence the bit rate such as the quantization step size, the rounding offset and the quantization matrix.
For illustrative purposes, the quantization process of the MPEG-4 AVC Standard will now be discussed. Mathematically, in the encoder the transformed coefficients are quantized as follows:
                              Z          =                                    ⌊                                                                                        W                                                        q                                +                s                            ⌋                        ·                          sgn              ⁡                              (                W                )                                                    ,                            (        1        )            where W is the transformed coefficient and is quantized to a quantization level Z. Here, q is the quantization step size and s is the rounding offset. The function └.┘ rounds a value to the nearest integer and sgn(.) returns the sign of a signal. When the quantization matrix is applied, the coefficients are scaled first before the quantization process at the encoder. The range of W where it is quantized to 0 is referred to as the deadzone. In this particular case, the deadzone is Δ=2×(1−s)×q. At the decoder, the quantization level Z is reconstructed to the signal W′. This is called inverse quantization and is described mathematically as:W′=q·Z  (2)
A rate control algorithm adjusts the quantization parameters to obtain the target number of bits. A rate control algorithm is generally considered to be accurate when the number of bits used for some time interval is close or substantially equal to the allocated number of bits for this time interval. The specific time interval used to measure the rate control accuracy is defined depending on the applications. In some applications, the bit rate is preferred to be accurate on a picture level. In other applications such as broadcast, the bit rate is preferred to be accurate over a few frames due to the channel bandwidth constraint. In some other applications such as DVD authoring, the bit rate accuracy is often measured for the entire sequence and is considered accurate when the number of bits consumed by the entire movie meets the requirement.
Existing rate control algorithms assume the rounding offset and quantization matrix are constant and only adjust the quantization step size. The quantization step sizes have only a finite number of choices. They are represented by quantization indices, which are embedded in the encoded bitstream and conveyed to the decoder for reconstructing the video. With a limited number of quantization step sizes to choose from, existing rate control algorithms can hardly achieve very accurate control without loss of the quality. Loss of quality due to the rate control algorithm is often seen as quality inconsistence within a picture or across two or more pictures. A picture with lower quality may include visible artifacts that causes part of the picture to be displayed distorted.
To improve the rate control accuracy for a picture, a common approach in existing algorithms is to apply macroblock-level (MB-level) rate control. In the prior art, ρ-domain rate control method has been used to illustrate this approach. A ρ-domain rate control method assumes a linear relation between ρ and R, where ρ is the percentage of zero coefficients among the quantized transformed coefficients for an encoded region and R is the number of bits used for encoding the region. Mathematically, this may be represented by the following linear rate model:R(ρ)=θ(1−ρ)+Rc,  (3)where Rc is the number of non-texture bits used for encoding a region and θ is a constant.
Note that ρ monotonically increases with the quantization step size q, which implies that there is a one-to-one mapping between them. Therefore, given the target number of bits R, the estimated parameters θ and Rc, ρ-domain rate control method obtains the value of ρ, and therefore the quantization step size q based on the one-to-one ρ−q mapping.
Often the quantization step size q calculated above may not fall into the limited number of quantization step sizes that can be represented by quantization indices in the encoder. One approach is to let the macroblocks within the picture use quantization step sizes around q′, the quantization step size that is closest to q and can be represented by a quantization index. Moreover, the average quantization step size used by the picture is approximately q. In one embodiment, a macroblock can choose from quantization step sizes {q′−Δ1, q′, q′+Δ2}. Another approach is to update θ and Rc after each macroblock is encoded, and calculate q for each macroblock.
In another popular rate control algorithm referred to as TMN8, a quantization step size q is first calculated for a picture. The encoder starts encoding macroblocks with q. Then as more macroblocks are encoded, the rate control model parameters are updated and the quantization step size is updated on a macroblock basis.
One problem with the MB-level adjustment is that the quantization step sizes vary among macroblocks. In some cases, the difference between the quantization parameters can cause quality inconsistence within the picture.
Turning to FIG. 1, a method for rate control for video encoding is indicated generally by the reference numeral 100.
The method 100 includes a start block 105 that passes control to a function block 110. The function block 110 performs and/or otherwise involves an encoding setup, and passes control to a function block 115. The function block 115 initializes rate control parameters, and passes control to a loop limit block 120. The loop limit block 120 performs a loop over each macroblock in a current picture being processed, using a variable i, where i=1, . . . , number (#) of macroblocks in the picture, and passes control to a function block 125. The function block 125 calculates the quantization step size qi for macroblock i, and passes control to a function block 130. The function block 130 encodes macroblock i at quantization step size qi, and passes control to a function block 135. The function block 135 updates the rate control model parameters (for example, based on previously encoded macroblocks), and passes control to a loop limit block 140. The loop limit block ends the loop, and passes control to an end block 199.
It is to be appreciated that method 100 of FIG. 1, the rounding offset parameter is constant throughout the encoding process to which applies method 100.
It is to be further appreciated that function block 110 may optionally involve the aid of an operator. Moreover, the encoder setup corresponding to function block 110 may involve the setup of the target bit rate as well as the specification of any set of parameters involved in the encoding process.
Moreover, it is to be appreciated the calculation of the quantization step size qi for macroblock i performed by function block 125 may be based on, for example, the ρ-domain rate model or the TMN8 rate model.
The quantization step sizes used by all macroblocks, {qi}i=1, . . . , # of MBs may vary significantly and cause quality inconsistencies within the picture. To obtain more consistent quality in the picture, the encoder can choose to limit the dynamic range of the quantization step size. As a result, the number of bits that a picture actually uses may differ significantly from the target number of bits.
Thus, as described above, prior art rate control methods either lack rate control accuracy or create quality inconsistencies.